# -*- coding: utf-8 -*-
import javalang


# 提取类成员变量
def get_class_members(file_path):
    class_members = {}
    with open(file_path, 'r') as file:
        file_content =  file.read()
        tree = javalang.parse.parse(file_content)
        for path, node in tree:
            if isinstance(node, javalang.tree.ClassDeclaration):
                class_name = node.name
                class_members[class_name] = []
                for member in node.body:
                    if isinstance(member, (javalang.tree.FieldDeclaration)):
                        member_type = member.type.name
                        member_name = member.declarators[0].name
                        class_members[class_name].append((member_type, member_name))

    return class_members
